package com.lyt.springboot.util.algorithm;

public class S25 {

    public static void main(String[] args) {
        S25 s25 = new S25();
        String ss = s25.qqqq("acbfwhwhadb");
        String mm = s25.qqqq1("aaa bb aaa dd");
        System.out.println(ss);
        System.out.println(mm);
    }

    public String  qqqq(String a){
        if(a.length() == 0 || a == null) {
            return a;
        }
        StringBuilder  builder = new StringBuilder();
        for (int i = 0; i < a.length(); i++) {
            if(a.indexOf(a.charAt(i))==i) {
                builder.append(a.charAt(i));
            }
        }
        return builder.toString();

    }

    public String  qqqq1(String a) {
        StringBuilder  builder = new StringBuilder();
        String[] s = a.split(" ",-1);
        for (int i = 0; i < s.length; i++) {
            if(!builder.toString().contains(s[i])){
                builder.append(s[i]).append(" ");
            }
        }
        return builder.toString();
    }
}
